const softwareProjectName: string = process.env.SOFTWARE_PROJECT_NAME;
const version: string = process.env.VUE_APP_SOFTWARY_VERSION;
const headTitle: string = process.env.VUE_APP_HEAD_TITLE;
const envPath: string = '/';
const utilsPath: string = '/utils';
const apiPath: string = '/api';

const getConfPath: string =
  process.env.NODE_ENV === 'production'
    ? `${envPath}config/config.json`
    : `${envPath}${process.env.VUE_APP_CONF_FILE_PATH}`;

const url = {
  getSysInfo: `${utilsPath}/getSysInfo`,
  getFunConfig: `${utilsPath}/getfunconf`,
  logout: `${utilsPath}/logout`,
  login: `${utilsPath}/login`,
  get: `${utilsPath}/get`,
  gets: `${utilsPath}/gets`,
  /**
   *@deprecated :将在2.0版本后续版本中弃用 改用 /utils/event
   */
  fun: `${utilsPath}/fun`,
  getPartData: `${utilsPath}/getPartData`,
  getTreeGrid: `${utilsPath}/getTreeData`,
  createPartData: `${utilsPath}/createpartdata`,
  delPartData: `${utilsPath}/deletepartdata`,
  updataPartData: `${utilsPath}/updatepartdata`,
  setFunConf: `${utilsPath}/setFunConf`,
  getNav: `${utilsPath}/getnav`,
  setI18n: `${utilsPath}/lang`,
  getI18nPath: `${utilsPath}/getLang`,
  resetPWD: `${utilsPath}/resetpwd`,
  advq: `${utilsPath}/advq`,
  bpa: `${utilsPath}/bpa`,
  ctd: `${utilsPath}/ctd`,
  defv: `${utilsPath}/defVal`,
  upload: `${utilsPath}/upload`,
  importExcel: `${utilsPath}/importExcel`,
  exportXLSX: `${utilsPath}/expxls`,
  pmsCheck: `${utilsPath}/pmsCheck`,
  rfp: `${utilsPath}/rfp`,
  sprf: `${utilsPath}/sprf`,
  spf: `${utilsPath}/spf`,
  gpf: `${utilsPath}/gpf`,
  dpr: `${utilsPath}/dpr`,
  vce: `${utilsPath}/vce`,
  csq: `${utilsPath}/csq`,
  // uploadFile: `${utilsPath}/updAtt`,
  // loadFile: `${utilsPath}/downdAtt`,
  delFile: `${utilsPath}/delAtt`,
  gan: `${utilsPath}/autoNum`,
  afd: `${utilsPath}/afd`,
  uafd: `${utilsPath}/uafd`,
  sfa: `${utilsPath}/sfa`,
  gam: `${utilsPath}/gam`,
  gal: `${utilsPath}/gal`,
  apa: `${utilsPath}/apa`,
  pca: `${utilsPath}/pca`,
  ppf: `${utilsPath}/ppf`,
  aftnl: `${utilsPath}/aftnl`,
  sup: `${utilsPath}/sup`,
  getFilterList: `${utilsPath}/gpfd`,
  gpmp: `${utilsPath}/gpmp`,
  chkToken: `${utilsPath}/chkToken`,
  sdq: `${utilsPath}/sdq`,
  getSnowID: `${utilsPath}/getSnowID`,
  rulectl: `${utilsPath}/rulectl`,
  getAccSet: `${utilsPath}/getAccSet`,
  rule: `${utilsPath}/rule`,
  download: `${apiPath}/download`,
  // 权限处理
  pmsHandle: `${utilsPath}/pmsHandle`,
  // 国际化日志
  i18nLog: `${utilsPath}/i18nlog`,
  // 获取视图信息
  getView: `${utilsPath}/getView`,
  // 获取功能表字段
  getFun: `${utilsPath}/getfun`,
  // 获取功能信息 主功能 副功能 功能ID getfun也会获取同样的信息
  getFunInfo: `${utilsPath}/getfuninfo`,
  // 编辑锁
  editLock: `${utilsPath}/editLock`,
  getViewByTableField: `${utilsPath}/getviewbytablefield`,
  // 事件
  event: `${utilsPath}/event`,
  // 导出xml和 schema
  exportXml: `${utilsPath}/exportxml`,
  // 获取外部用户验证密文
  getKey: `${utilsPath}/getkey`,
  // 获取新建功能sql
  makefunsqls: `${utilsPath}/makefunsqls`,
  scadaRead: `${utilsPath}/scadaRead`,
  scadaWrite: `${utilsPath}/scadaWrite`,
  scadaControl: `${utilsPath}/scadaControl`,
  scadaGetEcBox: `${utilsPath}/scadaGetEcBox`,
  scadaQueryData: `${utilsPath}/scadaQueryData`,
  // 订阅scada
  scadaSubscribe: `${utilsPath}/scadaSubscribe`,
  // 取消订阅scada
  scadaUnSubscribe: `${utilsPath}/scadaUnSubscribe`,
  // scada标签
  scadaEventNotify: `${utilsPath}/scadaEventNotify`,

  // 通过key获取token
  getToken: `${apiPath}/gettoken`,
  // 前端文件请求路径
  // getConfFilePath: `${envPath}config/config.json`,
  getConfFilePath: getConfPath,
  // getHelpFilePath: `${envPath}help/help.md`
  // 图标字库
  getIconFontPath: `${envPath}font/iconfont.css`,
  // 帮助文档
  getDeveloperFilePath: `${envPath}devDoc/index.html`,
  getUserFilePath: `${envPath}userDoc/index.html`,
  chkKey: `${apiPath}/gettoken`
};

const routerPath = {
  root: {
    path: `${envPath}`,
    name: 'rootPath'
  },
  home: {
    path: `${envPath}`,
    name: 'homePath'
  },
  login: {
    path: `${envPath}login`,
    name: 'loginPath'
  },
  page404: {
    path: `${envPath}404`,
    name: '404Path'
  },
  test: {
    path: `${envPath}test`,
    name: 'testPath'
  },
  singleSign: {
    path: `${envPath}app`,
    name: 'appPath'
  }
};
const cookies = {
  tokenKey: 'token',
  userNoKey: 'userNo',
  userNameKey: 'userName',
  userIdKey: 'userId',
  dbNameKey: 'dbName',
  languageKey: 'language'
};
const msg = {
  // aaaaaa
  saveSuccess: '50001,FE,0,saveSuccess',
  // 未定义的类型
  UndefinedType: '-106,FE,80,Undefined type!',
  // 传参为空
  ParameterIsEmpty: '-107,FE,80,The parameter is empty!',
  // 不能识别的元素
  Unrecognizedlement: '-111,FE,80,Unrecognized element!',
  // 数据空
  DataIsEmpty: '-119,FE,80,Data is empty!',
  // 用户名或密码错误
  DBLoginAuthErr: '-500,FE,50,wrong user name or password!',
  // 类型转换失败
  DBTypeConversionFailed: '-501,FE,80,Type conversion failed!',
  // 字符串为空
  ErrStringIsNull: '-502,FE,50,String is empty!',
  // 无效的Token
  ErrInvalidToken: '-506,FE,50,Invalid token!',
  // 无效的参数
  ErrInvalidParams: '-507,FE,50,Invalid parameter!',
  // 生成json错误
  ErrCreateJSON: '-508,FE,80,JSON generation error!',
  // 令牌与用户不匹配
  ErrTokenOrID: '-509,FE,90,Token does not match user!',
  // json格式不正确
  NotValidJSON: '-510,FE,80,Not a valid json format file!',
  // 缺少i18n属性
  NotI18nAttr: "-511,FE,80,json file has no 'i18n' element!",
  // 不能识别的命令
  Unrecognizedcommands: '-512,FE,90,Unrecognized commands!',
  // 数据库事务已打开
  TransactionOpened: '-513,FE,80,Database transaction opened',
  // 未开启事务
  TransactionNotOpened: '-514,FE,50,Transaction not opened',
  // 无法识别的字段数据类型
  UnrecognizedFieldDataType: '-515,FE,80,Unrecognized field data type!',
  // 字段表达式错误
  FieldExpressionError: '-516,FE,80,Field expression error!',
  // 请求失败
  RequestFailed: '-517,FE,80,Request failed!',
  // 文件内容为空
  FileContentIsEmpty: '-518,FE,80,File content is empty!',
  // 列数超出100
  ColumnsExceeded: '-519,FE,80,The number of columns exceeds the limit!',
  // 字段类型不能识别
  FieldTypeErr: '-520,FE,80,The field type is not recognized!',
  // 表字段不能改为子查询字段
  ErrChangeSubqueryField:
    '-521,FE,80,Table fields cannot be changed to subquery fields!',
  // 存储过程返回不合法的json
  SPReturnInvalidJSON: '-522,FE,80,The stored procedure returns invalid JSON!',
  // 空编号
  EmptyNumber: '-523,FE,80,Empty number!',
  // 编号超过指定长度
  SuperLong: '-524,FE,80,Number exceeds set length!',
  // 无法识别的文件类型
  UnrecognizedFileType: '-525,FE,80,Unrecognized file type!',
  // 不接受的文件类型
  FileTypeDeny: '-526,FE,80,File type not accepted!',
  // 文件不存在
  FileNotExist: '-527,FE,80,File does not exist!',
  // 文件名格式不合法
  InvalidFileName: '-528,FE,80,File name format is invalid!',
  // 不合法的JSON串
  InvalidJSON: '-529,FE,80,JSON string is invalid!',
  // json表达式不是一个数组
  JSONNotArray: '-530,FE,80,JSON expression is not an array!',
  // 权限角色不存在
  PMSRoleNotExist: '-531,FE,80,Permission role does not exist!',
  // 找不到审核流程节点
  FlowIDisNULL: '-532,FE,80,Approval process node not found!',
  // 子查询SQL语法缺少where条件
  SubquerySQLSyntaxError:
    '-533,FE,80,Subquery SQL syntax is missing the where condition!',
  // 同级别多个重复的角色
  RoleConflict: '-534,FE,80,Multiple duplicate roles at the same level',
  // 流程图缺少开始节点
  MissingStartNode: '-535,FE,80,Flowchart missing start node!',
  // 没有要审批的对象
  NoUsersToApprove: '-536,FE,80,There are no objects to approve!',
  // 重复提交送批
  RepeatedSubmission: '-537,FE,80,Repeated submission for approval!',
  // 清单中含有不合法的帐单
  ContainsIllegalBills: '-538,FE,80,The list contains illegal bills!',
  // 正在送批中
  SendingApproval: '-539,FE,80,Sending approval',
  // 制单人为空
  BillerIsEmpty: '-540,FE,80,Biller is empty!',
  // 需要走呈批流程
  NeedApproval: '-541,FE,80,Need to go through the approval process!',
  // 由管理模块接管
  TakenOverByBM: '-542,FE,80,Taken over by management module!',
  // 非法IP地址
  IllegalIPaddress: '-543,FE,80,Illegal IP address!',
  // 非法端口号
  IllegalHostPort: '-544,FE,80,Illegal host port!',
  // 用户不存在
  UserNotExist: '-545,FE,80,user does not exist!',
  // 工作ID超出数量
  WorkerIDExcess: '-546,FE,90,Worker ID excess of quantity!',
  // MTO没有指定描述字段
  DescFieldIsEmpty: '-547,FE,80,Description field is empty!',
  // 无法序列化 bson
  SerializeBSONFailed: '-548,FE,80,Failed to serialize BSON!',
  // 无法序列化 json
  SerializeJSONFailed: '-549,FE,80,Failed to serialize JSON!',
  // 系统数据库资料缺失
  SysDBDataMissing: '-550,FE,99,Missing data in system database!',
  // 主功能名空
  MainFunNameIsNull: '-1001,FE,90,Main function not specified!',
  // 外键约束
  ForeignKeyConstraint: '-1002,FE,80,Foreign key constraint!'
};
// 全局变量
const globalVar = {
  // 数据库类型
  dbType: {
    MYSQL: 'mysql',
    MONGO: 'mongo'
  },
  // 表名|集合名
  tableName: {
    // 权限动作表名
    PMS_ACT: '_sys_roleobj_funs_action',
    // 权限功能表名
    PMS_FUN: '_sys_roleobj_funs',
    // 角色表名
    PMS_ROLE: '_sys_role',
    // mongo 图数据表名
    MONGO_GRAPH: '_sys_graph',
    MYSQL_GRAPH: 'mongo_xcsys__sys_graph',
    // pubAPI
    PUB_API: '_sys_publicprocess',
    CONTROL_CFG: '_sys_control_cfg',
    SYS_FUN: '_sys_fun',
    RULE_LIB: '_sys_rule_lib',
    RULE_RESOURCES: '_sys_rule_resources',
    // 打印配置
    SYS_PRINTSET: '_sys_printset',
    // 用户偏好
    SYS_USER_PREFE: '_sys_user_prefe',
    BPMN_LIB: '_sys_bpmn_lib',
    // SYS_INTERNAL_LIAISON_SHEET: 'test1_internal_liaison_sheet', // _sys_internal_liaison_sheet
    // SYS_INTERNAL_LIAISON_SHEET_DET: 'test1_internal_liaison_sheet_det', // _sys_internal_liaison_sheet_det
    // SYS_INTERNAL_LIAISON_SHEET_LOG: 'test1_internal_liaison_sheet_log', // _sys_internal_liaison_sheet_log,
    SYS_INTERNAL_LIAISON_SHEET: '_sys_internal_liaison_sheet', // _sys_internal_liaison_sheet
    SYS_INTERNAL_LIAISON_SHEET_DET: '_sys_internal_liaison_sheet_det', // _sys_internal_liaison_sheet_det
    SYS_INTERNAL_LIAISON_SHEET_LOG: '_sys_internal_liaison_sheet_log', // _sys_internal_liaison_sheet_log,
    SYS_MSG: '_sys_msg',
    SYS_LAYOUT: '_sys_layout'
  },
  // 功能名
  funName: {
    // 权限动作功能名
    PMS_ACT: '_sys_roleobj_funs_action',
    // 权限动作功能名
    PMS_RULE: '_sys_roleobj_funs_rule',
    // 权限功能功能名
    PMS_FUN: '_sys_roleobj_funs',
    // 角色
    PMS_ROLE: '_sys_role',
    // 角色明细
    PMS_ROLE_DET: '_sys_role_detail',
    // 编辑锁
    EDIT_LOCK: '_sys_edit_lock',
    SYS_LAYOUT: '_sys_layout',
    SYS_CUSTOMBTN_STATUS: '_sys_custombtn_status',
    SYS_KEY_WORD: '_sys_keyword',
    SYS_BASE_SET: '_sys_base_set',
    FUN: '_sys_fun',
    BPMN_LIB: '_sys_bpmn_lib',
    SYS_DEF_TEMP_SET: '_sys_def_temp_set',
    SYS_INTERNAL_LIAISON_SHEET: '_sys_internal_liaison_sheet'
  },
  fieldName: {
    // 权限角色ID
    pmsRoleID: '_sys_role_id',
    title: 'title',
    // 功能ID
    funID: '_sys_fun_id',
    funConfig: 'fun_config',
    graphData: 'graph_data',
    verNum: 'ver_num',
    fCode: 'f_code',
    dslCode: 'dsl_code',
    // 功能组ID
    funGroupID: '_sys_fun_group_id',
    // 功能组m2o描述虚拟字段
    m2oFunGroupTitle: 'm2o|_sys_fun_group_id|_sys_fun_group|title',
    // 功能m2o描述虚拟字段
    m2oFunTitle: 'm2o|_sys_fun_id|_sys_fun|title',
    /* 外观元素m2o描述虚拟字段 */
    m2oAspEleIdTitle: 'm2o|_sys_aspect_element_id|_sys_aspect_element|title',
    // 权限功能功能名 id
    roleobjFunsId: '_sys_roleobj_funs_id',
    // 帐套ID
    accountSetID: '_sys_account_set_id',
    // 主单ID
    masterBillId: 'master_bill_id',
    // 节点ID
    nodeID: 'node_id',
    // id
    ID: 'id',
    libGraphID: '_sys_graph_id',
    pubApiName: 'f_name',
    fNumber: 'f_number',
    parentId: 'p_id',
    _audited_: '_audited_',
    // 消息部分
    msgType: 'data_type_i',
    msgContent: 'content',
    msgStatus: 'f_status',
    msgSender: 'sender_no',
    msgSendTime: 'create_time',
    msgReceiver: 'user_no',
    msgCategory: 'category'
  },
  // 国际化
  i18n: {
    enUS: 'en-US',
    zhCN: 'zh-CN',
    zhTW: 'zh-TW'
  },
  spName: {
    // vce API 专用存储过程
    apiVceSpName: '_sys_p_fieldCalc',
    webApiReq: '_sys_post_ifc_webapi',
    // 打开新增功能面板 的 系统策略
    addFunSetup: '_sys_add_fun_setup',
    // 打开新的功能页签
    jumpToFun: 'clickPageJump'
  },
  sysInfo: {
    // 版本信息
    versionType: process.env.VUE_APP_VERSION_TYPE
  },
  compName: {
    BASE_GRID: 'o-base-grid',
    BASE_PANEL: 'o-base-panel'
  }
};

const setupPanelConf = {
  basePanelDefFieldAuditStatus: {
    fieldID: '380299312925507584',
    field: 'audit_status',
    type: 'int(5)',
    defValue: 0,
    selectionID: '408533419782307840'
  },
  basePanelDefFieldFStatus: {
    fieldID: '406300130250063872',
    field: 'f_status', // _status_
    type: 'int(5)',
    defValue: 0,
    selectionID: '408536001896513536'
  }
};

const setupGraphConf = {
  graphDefFieldNodeId: {
    fieldID: '401950968012341248',
    field: 'node_id',
    type: 'varchar(500)'
  },
  graphDefFieldMasterBillId: {
    fieldID: '378075409763270656',
    field: 'master_bill_id',
    type: 'bigint(20)'
  }
};
const setupRefGraphConf = {
  graphDefFieldMasterBillId: {
    fieldID: '378075409763270656',
    field: 'master_bill_id',
    type: 'bigint(20)'
  },
  graphDefFieldGraphLibId: {
    fieldID: '441516307377037312',
    field: '_sys_graph_id',
    type: 'bigint(20)'
  }
};

const setupAuditDefaultFieldsConf = {
  audited: {
    fieldID: '549069322199257088',
    field: '_audited_',
    type: 'int(5)',
    selectionID: '408533419782307840',
    defValue: 0
  },
  status: {
    fieldID: '549070605010358272',
    field: '_status_',
    type: 'int(5)',
    selectionID: '408536001896513536',
    defValue: 0
  },
  previousStatus: {
    fieldID: '549070114536837120',
    field: '_previous_status_',
    type: 'int(5)',
    selectionID: '408536001896513536',
    defValue: 0
  }
};

const setupRecordsDefaultFieldsConf = {
  createor: {
    fieldID: '408513584163717120',
    field: 'createor',
    type: 'bigint(20)',
    many2one: {
      toTable: '_sys_user',
      toField: 'user_name'
    }
  },
  modifyUser: {
    fieldID: '222301287968935948',
    field: 'last_modify_user',
    type: 'bigint(20)',
    many2one: {
      toTable: '_sys_user',
      toField: 'user_name'
    }
  },
  createTime: {
    fieldID: '222301287968935950',
    field: 'create_time',
    type: 'datetime(3)'
  },
  modifyTime: {
    fieldID: '222301287968935947',
    field: 'last_modify_time',
    type: 'datetime(3)'
  }
};

export default {
  headTitle,
  routerPath,
  cookies,
  url,
  msg,
  globalVar,
  setupPanelConf,
  setupGraphConf,
  version,
  softwareProjectName,
  setupRefGraphConf,
  setupAuditDefaultFieldsConf,
  setupRecordsDefaultFieldsConf
};
